import org.w3c.dom.ls.LSOutput;

import java.util.Arrays;

public class Test1 {
    //实现一个方法 transform, 以数组为参数, 循环将数组中的每个元素 乘以 2
    // 并设置到对应的数组元素上. 例如 原数组为 {1, 2, 3}, 修改之后为 {2, 4, 6}
    /*public static void transform(int[] n) {
        for (int i = 0; i < n.length; i++) {
            n[i] = n[i] * 2;
        }
    }
    public static void main(String[] args) {
        int[] a = {1 , 2 , 3};
        transform(a);
        System.out.println(Arrays.toString(a));//输出数组的方法

    }*/
    //求一个数组的平均值
    /*public static double avg(double[] n){
        double temp = 0;
        for (int i = 0; i < n.length; i++) {
            temp = temp + n[i];
        }
        return temp / (n.length);
    }
    public static void main(String[] args) {
        double[] a = {1 , 2 , 3 , 4};
        System.out.println(avg(a));

    }*/
    //java中创建数组的几种方式
    /*public static void main1(String[] args) {
        //第一种方式，直接赋值
        int[] intArray = {1, 2, 3, 4, 5};
        String[] stringArray = {"apple", "banana", "cherry"};
        //第二种，动态初始化
        int[] a = new int[10];
        a[0] = 1;
        a[1] = 3;
        a[2] = 3;
        a[3] = 4;
        a[4] = 5;
        a[5] = 6;
        a[6] = 7;
        a[7] = 8;
        a[8] = 9;
        //多维数组的创建方法
        int[][] n = {{1,2,3},{4,5,6},{7,8,9}};

    }*/
    //调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序
    /*public static int[] sort(int[] n){
        if (n == null || n.length == 0) {
            return n;
        }
        int right = n.length - 1;
        int left = 0;
        while(left < right){
            while(left < right && n[left] % 2 != 0){//当判断指针的条件时用left和right，
                                                    // 当要用到数组里面时需要n[left]
                left++;
            }
            while(left < right && n[right] % 2 == 0){
                right--;
            }
            if(left < right){
                int temp = n[left];
                n[left] = n[right];
                n[right] = temp;
            }
        }
        return n;
    }
    public static void main(String[] args) {
        int[] n = {1 , 2 , 3 , 4, 5};
        sort(n);
        System.out.println(Arrays.toString(n));
    }*/
    //给定一个整型数组, 实现冒泡排序(升序排序)
    /*public static int[] bubbleSort(int[] n){
        int temp = 0;
        for (int i = 0; i < n.length-1; i++) {
            for (int j = 1; j < n.length-i; j++) {
                if(n[j] < n[j-1]){
                    temp = n[j];
                    n[j] = n[j-1];
                    n[j-1] = temp;
                }
            }
        }
        return n;
    }
    public static void main(String[] args) {
        int a[] = {2,1,5,7,4};
        bubbleSort(a);
        System.out.println(Arrays.toString(a));

    }*/
    //两数之和
    /*public static int[] twoSum(int[] nums, int target) {
        int n = nums.length;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (nums[i] + nums[j] == target) {
                    return new int[]{i, j};
                }
            }
        }
        return new int[]{};
    }

    public static void main(String[] args) {
        int[] nums = {2, 7, 11, 15};
        int target = 9;
        int[] result = twoSum(nums, target);
        System.out.println(Arrays.toString(result));
    }*/
    //只出现一次的数字
    public static int num(int[] a){
        int n = a.length;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if(a[i] != a[j]){
                    
                }
            }
        }
    }
    public static void main(String[] args) {

    }
}
